home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Kellogg's Amérique
/
Kellogg's Amérique
/
terre_feu.swf
/
scripts
/
jeux
/
Chrono.as
next >
Wrap
Text File
|
2020-08-04
|
3KB
|
150 lines
package jeux
{
import flash.display.MovieClip;
import flash.events.TimerEvent;
import flash.text.TextField;
import flash.utils.Timer;
public class Chrono extends MovieClip
{
public var _laps:Number;
public var secondes:TextField;
const LAPS:Number = 1000;
public var cpt_chrono:Timer;
public var _temps:Number;
public var sec:Number;
public var min:Number;
public var _sens:Boolean;
const SENS:Boolean = true;
public var fonction_fin:Function;
public var minutes:TextField;
public var _fin_chrono:Boolean;
const TEMPS:Number = 120;
public function Chrono()
{
super();
_temps = TEMPS;
_laps = LAPS;
_sens = SENS;
_fin_chrono = false;
cpt_chrono = new Timer(_laps,1);
cpt_chrono.addEventListener("timer",fin_laps);
minutes.embedFonts = true;
secondes.embedFonts = true;
afficher();
}
public function lancer() : *
{
cpt_chrono.start();
}
public function fin_laps(param1:TimerEvent) : *
{
if(_temps)
{
if(_sens)
{
--_temps;
}
else
{
++_temps;
}
afficher();
cpt_chrono = new Timer(_laps,1);
cpt_chrono.start();
cpt_chrono.addEventListener("timer",fin_laps);
}
else
{
_fin_chrono = true;
trace("fin chrono ***");
if(fonction_fin != null)
{
fonction_fin();
}
}
}
public function set temps(param1:Number) : *
{
_temps = param1;
afficher();
}
public function get laps() : Number
{
return _laps;
}
public function get temps() : Number
{
return _temps;
}
public function set sens(param1:Boolean) : *
{
_sens = param1;
}
public function get fin_chrono() : Boolean
{
return _fin_chrono;
}
public function set laps(param1:Number) : *
{
_laps = param1;
cpt_chrono = new Timer(_laps,1);
}
public function arreter() : *
{
cpt_chrono.stop();
}
public function get sens() : Boolean
{
return _sens;
}
public function afficher() : *
{
min = Math.floor(_temps / 60);
sec = _temps - min * 60;
if(min > 9)
{
minutes.text = min.toString();
}
else
{
minutes.text = "0" + min.toString();
}
if(sec > 9)
{
secondes.text = sec.toString();
}
else
{
secondes.text = "0" + sec.toString();
}
}
}
}